package com.wanxi.system;

import java.util.Scanner;

/**
 * 答应M到N之间的偶数
 * 1.要给m和n赋值
 * 2.要又一个方法
 * 3.要判断n和m之间的大小
 */
public class PrintEvenMandN {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数");
        int n = scanner.nextInt();
        System.out.println("请输入第二个数");
        int m = scanner.nextInt();
//        boolean isRight = judgeBigSmall(n, m);
//        if (isRight) {
////           m=?
//            System.out.println("重新输入m的值");
//            m = scanner.nextInt();
//        }
        m = newValue(n, m);
        printEven(n, m);
    }

    /**
     * 如果n大于m，则让用户重新输入一个值，否则不变
     *
     * @param n
     * @param m
     * @return
     */
    private static int newValue(int n, int m) {
        if (n > m) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请重新输入一个数字,要比" + n + "大");
            return scanner.nextInt();
        } else {
            return m;
        }
    }

    private static boolean judgeBigSmall(int n, int m) {
        if (n > m) {
            return true;
        } else {
            return false;
        }
    }

    private static void printEven(int n, int m) {
        for (int i = n; i <= m; i++) {
            if (i % 2 == 0) {
                System.out.println("偶数为：" + i);
            }
        }
    }
}
